package com.xiaoping.recyclerview4;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    
    private RecyclerView mReyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        List<String> titles = new ArrayList<>();
        titles.add("1111");
        titles.add("2222");
        titles.add("3333");
        titles.add("4444");
        titles.add("5555");
        titles.add("6666");
        titles.add("7777");
        titles.add("8888");
        titles.add("9999");
        mReyclerView = findViewById(R.id.recycler_view);
        mReyclerView.setLayoutManager(new LinearLayoutManager(MainActivity.this));
        mReyclerView.setAdapter(new MyAdapter(MainActivity.this, titles, new MyAdapter.OnClickItemListener() {
            @Override
            public void onClickItemListener(int postion) {
                Toast.makeText(MainActivity.this, "click" + postion, Toast.LENGTH_SHORT).show();
            }
        }));
    }
}